﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using Light.Framework.Model;
using Light.Utility;

namespace Light.Weixin.Model
{

    /// <summary>
    /// 固定回复内容
    /// </summary>
    [ActiveRecord]
    [ImportField("固定回复内容")]
    public class WxAnswer : Entity
    {
        /// <summary>
        /// 消息类型
        /// </summary>
        [Property("FType")]
        public WxAnswerType Type { get; set; }

        /// <summary>
        /// 关键字
        /// </summary>
        [Property]
        [ImportField("关键字")]
        [Searchable("关键字")]
        public string Keywords
        {
            get
            {
                string value = this.GetValue<string>("Keywords", string.Empty);
                if (Type == WxAnswerType.Subscribe)
                    value = WxAnswerType.Subscribe.ToString().ToLower();
                return value;
            }
            set
            {
                this.SetValue("Keywords", value != null ? value.ToLower() : string.Empty);
            }
        }

        /// <summary>
        /// 回复内容
        /// </summary>
        [Property("FContent")]
        [ImportField("回复内容")]
        [Searchable("回复内容")]
        public string Content { get; set; }

        /// <summary>
        /// 所属微信公众号
        /// </summary>
        [BelongsTo("WxApp_ID")]
        public WxApp WxApp { get; set; }
    }
}
